<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>日志</title>
    <link href="../../layuiadmin/js/adm/css/bootstrap.css" rel="stylesheet">
    <script src="../../layuiadmin/js/adm/js/vue.js"></script>
    <script src="../../layuiadmin/js/adm/js/vue-resource.js"></script>
    <script src="../../layuiadmin/js/adm/js/jquery.min.js"></script>
    <script src="../../layuiadmin/js/adm/js/jquery.cookie.js"></script>
    <script src="../../layuiadmin/js/adm/js/bootstrap.js"></script>
    <script type="text/javascript" src="../../layuiadmin/js/finance/js/jquery.table2excel.js"></script>
</head>
<body>
<div id="app" class="container-fluid" style="margin-top: 25px">
    <form action="" method="POST" class="form-horizontal form-inline">
        <div class="row">
            <div class="col-xs-12" style="padding-left: 10%">
                <input type="text" class="form-control" v-model="input" >&nbsp;
                <!-- 案号搜索 -->
                <select class="form-control" style="width: 8%" v-model="inputtype">
                    <option :value="-1">选择搜索类型</option>
                    <option :value="1">案号搜索</option>
                    <option :value="2">客户名称搜索</option>
                    <option :value="3">律师搜索</option>
                </select>&nbsp;

                <!-- 日志类型 -->
                <select class="form-control" style="width: 13%" v-model="typeID" >
                    <option :value="-1">日志类型</option>
                    <option v-for="item in logtype"  :value="item.typeId">{{item.logSecondId==0?item.logStairName:"&nbsp;&nbsp;&nbsp;--"+item.logStairName}}</option>
                </select>&nbsp;

                <!-- 案件类型 -->
                <select class="form-control" style="width: 10%" v-model="casetype">
                    <option :value="-1">案件类型</option>
                    <option v-for="castt in caseType" :value="castt.caseTypeid">{{castt.typeName}}</option>
                </select>&nbsp;

                <!-- 选择公开状态 -->
                <select class="form-control" style="width: 10%" v-model="state">
                    <option value="-1">选择公开状态</option>
                    <option value="Y">已公开</option>
                    <option value="N">未公开</option>
                </select>&nbsp;

                <input type="date" class="form-control" v-model="kdate" >&nbsp;
                <input type="date" class="form-control" v-model="jdate" >&nbsp;
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12" style="padding-left: 9%; margin-top: 20px">
                <div class="col-xs-1"><input type="button" class="btn btn-primary" value="检索" @click="postfuzzyquery()"></div>
                <div class="col-xs-1"><input type="button"  class="btn" onclick="out()" value="导出"></div>
            </div>
        </div>
    </form>

    <div class="row" id="alls" style="padding: 0 10% 0 10%;margin-top: 20px">
        <table class="table table-condensed table-hover">
            <thead>
            <tr>
                <th>日志类型</th>
                <th>案号</th>
                <th>客户名称</th>
                <th>开始时间</th>
                <th>自报时间</th>
                <th>工作描述</th>
                <th>公开状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr v-for="item in loglist" :key="item.logId">
                <td style="vertical-align: middle">{{item.logSecondId.logStairName}}</td>
                <td style="vertical-align: middle">{{item.caseId.caseId}}</td>
                <td style="vertical-align: middle">{{item.caseId.clientId.clientName}}</td>
                <td style="vertical-align: middle">{{item.startTime|formatDate}}</td>
                <td style="vertical-align: middle">{{item.duration}}</td>
                <td style="vertical-align: middle">{{item.description}}</td>
                <td style="vertical-align: middle" v-if="item.state=='Y'">已公开</td>
                <td style="vertical-align: middle" v-if="item.state=='N'">未公开</td>
                <td style="vertical-align: middle">
                    <div class="dropdown">
                        <button class="btn btn-default dropdown-toggle btn-sm" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                            更多
                            <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                            <li><a href="#"  @click.prevent="psothref(item.logId)">查看</a></li>
                            <li><a href="#" @click.prevent="postdelete(item.logId)">删除</a></li>
                            <li><a href="#" @click.prevent="postupdate(item.logId)">修改</a></li>
                        </ul>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>


<script>
    var a="";
    var vm=new Vue({
        el:'#app',
        data:{
            loglist:[       //整体集合

            ],
            caseType:[         //案件类型

            ],
            logtype:[       //日志类型
            ],
            state:"-1",   //公开状态
            kdate:"",   //开始时间
            jdate:"",   //结束时间
            typeID:"-1",
            casetype:"-1",  //案件类型
            input:"",           //input框
            inputtype:"-1"        //模糊查询选项
        },
        created () {
            this.postinfo()
            this.postcasetype()
            this.postlogtype()
        },
        filters: {
            formatDate: function (value) {      //将时间戳修改为时间单位格式
                let date = new Date(value);
                let y = date.getFullYear();
                let MM = date.getMonth() + 1;
                MM = MM < 10 ? ('0' + MM) : MM;
                let d = date.getDate();
                d = d < 10 ? ('0' + d) : d;
                let h = date.getHours();
                h = h < 10 ? ('0' + h) : h;
                let m = date.getMinutes();
                m = m < 10 ? ('0' + m) : m;
                let s = date.getSeconds();
                s = s < 10 ? ('0' + s) : s;
                return y + '-' + MM + '-' + d ;
                // return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
            }
        },
        methods: {
            postupdate(logId){
                window.location.href="log_update.html?id="+logId;
            },
            postdelete(logId){
                this.$http.post('http://localhost:8080/log_table/delete',{"logId":logId},{emulateJSON:true}).then(result =>{
                    var dat=eval("("+result.body+")")
                    if(dat=="1"){
                        alert("删除成功")
                        this.postinfo()
                    }else{
                        alert("删除失败")
                    }
                })
            },
            psothref(logId){
                window.location.href="log_tableAdd.html?id="+logId;
            },

            postinfo(){     //查询全部
                var userId=$.cookie("redisId")
                this.$http.post('http://localhost:8080/log_table/listall',{"userId":userId},{emulateJSON:true}).then(result =>{
                    var dat=eval("("+result.body+")")
                    if(dat!=null&&dat!=""){
                        this.loglist=new Array()   //每次重新new一个list集合给定义的list集合
                        for(var i=0;i<dat.length;i++){
                            this.loglist.push(dat[i])
                        }
                    }else{
                        alert("获取失败")
                    }
                })
            },
            postcasetype(){         //案件类型
                this.$http.post('http://localhost:8080/log_table/caseType',{},{emulateJSON:true}).then(result =>{
                    var dat=eval("("+result.body+")")
                    if(dat!=null&&dat!=""){
                        this.caseType=new Array()   //每次重新new一个list集合给定义的list集合
                        for(var i=0;i<dat.length;i++){
                            this.caseType.push(dat[i])
                        }
                    }else{
                        alert("获取失败")
                    }
                })
            },
            //模糊查询
            postfuzzyquery(){
                var userId=$.cookie("redisId")
                this.$http.post('http://localhost:8080/log_table/fuzzyquery',{
                    "state":this.state,"kdate":this.kdate,"jdate":this.jdate,"typeID":this.typeID,
                    "casetype":this.casetype,
                    "input":this.input,
                    "inputtype":this.inputtype,
                    "userId":userId
                },{emulateJSON:true}).then(result =>{
                    var dat=eval("("+result.body+")")
                    if(dat!=null&&dat!=""){
                        this.loglist=new Array()   //每次重新new一个list集合给定义的list集合
                        for(var i=0;i<dat.length;i++){
                            this.loglist.push(dat[i])
                        }
                    }else{
                        alert("未查询到记录")
                    }
                })
            },
            postlogtype(){          //日志类型
                this.$http.post('http://localhost:8080/log_table/logtype',{},{emulateJSON:true}).then(result =>{
                    var dat=eval("("+result.body+")")
                    if(dat!=null&&dat!=""){
                        this.logtype=new Array()   //每次重新new一个list集合给定义的list集合
                        for(var i=0;i<dat.length;i++){
                            this.logtype.push(dat[i])
                        }
                    }else{
                        alert("获取失败")
                    }
                })
            }
        


        }

    })

    //导出
    function out() {
        $("#alls").table2excel({
            //table2excel插件的可用配置参数有：
            exclude: ".noExl",//   exclude：不被导出的表格行的CSS class类。
            name: "Excel Document Name",//   name：导出的Excel文档的名称
            filename: "myFileName",//   filename：Excel文件的名称。
            exclude_img: true,//   exclude_img：是否导出图片。
            exclude_links: true,//   exclude_links：是否导出超链接
            exclude_inputs: true//    exclude_inputs：是否导出输入框中的内容
        });
    }
</script>

</body>
</html>